package src.F_CollectionFramework;

// 自定义泛型
public class F02_GenericityTest {
    public static void main(String[] args) {
        Genericity genericity = new Genericity(); // 没加泛型三个参数类型
        Object t = genericity.getT();
        Object e = genericity.getE();
        int i = genericity.getI();
        Genericity<String, Object> genericity1 = new Genericity(); // 加了泛型三个参数类型（不能使用基本数据类型，但是可以使用包装类）
        String t1 = genericity1.getT();
        Object e1 = genericity1.getE();
        int i1 = genericity1.getI();
        System.out.println(genericity1.methodF(new Integer(1)));
    }
}

// 自定义泛型类
class Genericity<T, E>{
    T t;
    E e;
    int i;

    // 泛型方法
    public <F> F methodF(F f){
        return f;
    }

    public Genericity() {
    }

    public Genericity(T t, E e, int i) {
        this.t = t;
        this.e = e;
        this.i = i;
    }

    public T getT() {
        return t;
    }

    public void setT(T t) {
        this.t = t;
    }

    public E getE() {
        return e;
    }

    public void setE(E e) {
        this.e = e;
    }

    public int getI() {
        return i;
    }

    public void setI(int i) {
        this.i = i;
    }

    @Override
    public String toString() {
        return "Genericity{" +
                "t=" + t +
                ", e=" + e +
                ", i=" + i +
                '}';
    }
}